// 下划线转换成驼峰
export function toHump(name) {
  return name.replace(/\_(\w)/g, function(all, letter){
    return letter.toUpperCase();
  });
}
// 驼峰转换下划线
export function toLine(name) {
  return name.replace(/([A-Z])/g,"_$1").toLowerCase();
}

export function randomInt(m,n){
  var aNumber = (n-1- m) * Math.random() + (m+1);
  var result = Math.floor(aNumber);
  return result
}

export function generateRandomInteger(digits) {
  // 生成一个指定位数的随机数字字符串
  let randomString = '';
  for (let i = 0; i < digits; i++) {
    randomString += Math.floor(Math.random() * 10);
  }
  // 将字符串转换为整数
  return parseInt(randomString, 10);
}

export function generateRandomString(length) {
  const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  let result = '';
  for (let i = 0; i < length; i++) {
    const randomIndex = Math.floor(Math.random() * characters.length);
    result += characters[randomIndex];
  }
  return result;
}
